#include <iostream>
#include <algorithm>
#include "scene.h"

scene::scene() : object()
{
    //ctor
}

scene::~scene()
{
    //dtor
}

void    scene::update()
{
    int i = 0;
    while (i != content.size())
    {
        //std::cout << i << "/" << content.size() << std::endl;
        content.at(i)->update();
        i++;
    }
}

void    scene::update_draw()
{
        int i = 0;
    while (i != content.size())
    {
        content.at(i)->update();
        content.at(i)->draw();
        i++;
    }
}

void    scene::draw()
{
    int i = 0;
    while (i != content.size())
    {
        //std::cout << i << "/" << content.size() << std::endl;
        content.at(i)->draw();
        i++;
    }
}

void    scene::add(object *obj)
{
    content.push_back(obj);
}

void    scene::remove(object *obj)
{
        content.erase(std::remove(content.begin(), content.end(), obj), content.end());
}

void    scene::removeall()
{
    content.clear();
}

void    scene::release(object *obj)
{
        content.erase(std::remove(content.begin(), content.end(), obj), content.end());
        delete(obj);
}

void    scene::releaseall()
{
    int i = 0;
    while (i != content.size())
    {
        //std::cout << i << "/" << content.size() << std::endl;
        delete(content.at(i));
        i++;
    }
    content.clear();
}
